//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101
//#include "stdafx.h"
#include "CubicNaturalSpline.h"
using namespace Cephei::QL::Math::Interpolations;
#include <gen/QL/Math/Interpolations/CubicInterpolation.h>
#undef HANDLE
#undef ABSTRACT
#undef STRUCT
Cephei::QL::Math::Interpolations::CCubicNaturalSpline::CCubicNaturalSpline (boost::shared_ptr<QuantLib::CubicNaturalSpline>& childNative, Object^ owner) : CCubicInterpolation(CCubicNaturalSpline::typeid)
{
#ifdef HANDLE
	_phCubicNaturalSpline = NULL;
#endif
	_ppCubicNaturalSpline = &childNative;
    _ppCubicInterpolation = new boost::shared_ptr<QuantLib::CubicInterpolation> (boost::dynamic_pointer_cast<QuantLib::CubicInterpolation> (*_ppCubicNaturalSpline));
}
Cephei::QL::Math::Interpolations::CCubicNaturalSpline::CCubicNaturalSpline (QuantLib::CubicNaturalSpline& childNative, Object^ owner) : CCubicInterpolation(CCubicNaturalSpline::typeid)
{
#ifdef HANDLE
	_phCubicNaturalSpline = NULL;
#endif
	_ppCubicNaturalSpline = new boost::shared_ptr<QuantLib::CubicNaturalSpline> (&childNative);
    _ppCubicInterpolation = new boost::shared_ptr<QuantLib::CubicInterpolation> (boost::dynamic_pointer_cast<QuantLib::CubicInterpolation> (*_ppCubicNaturalSpline));
    _CubicNaturalSplineOwner = owner;
    _CubicInterpolationOwner = owner;
}

Cephei::QL::Math::Interpolations::CCubicNaturalSpline::CCubicNaturalSpline (CCubicNaturalSpline^ copy) : CCubicInterpolation(CCubicNaturalSpline::typeid)
{
#ifdef HANDLE
	_phCubicNaturalSpline = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppCubicNaturalSpline = new boost::shared_ptr<QuantLib::CubicNaturalSpline> (copy->GetShared());
        _ppCubicInterpolation = new boost::shared_ptr<QuantLib::CubicInterpolation> (boost::dynamic_pointer_cast<QuantLib::CubicInterpolation> (*_ppCubicNaturalSpline));
    }
}
Cephei::QL::Math::Interpolations::CCubicNaturalSpline::CCubicNaturalSpline (System::Type^ t) : CCubicInterpolation(CCubicNaturalSpline::typeid)
{
#ifdef HANDLE
	_phCubicNaturalSpline = NULL;
#endif
	if (!t->IsSubclassOf(CCubicNaturalSpline::typeid))
		throw gcnew Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Math::Interpolations::CCubicNaturalSpline::CCubicNaturalSpline (QuantLib::Handle<QuantLib::CubicNaturalSpline>& childNative, Object^ owner)  : CCubicInterpolation(CCubicNaturalSpline::typeid)
{
	_phCubicNaturalSpline = &childNative;
	_ppCubicNaturalSpline = &static_cast<boost::shared_ptr<QuantLib::CubicNaturalSpline>>(childNative.currentLink());
    _ppCubicInterpolation = new boost::shared_ptr<QuantLib::CubicInterpolation> (boost::dynamic_pointer_cast<QuantLib::CubicInterpolation> (*_ppCubicNaturalSpline));
    _CubicNaturalSplineOwner = owner;
}
Cephei::QL::Math::Interpolations::CCubicNaturalSpline::CCubicNaturalSpline (QuantLib::Handle<QuantLib::CubicNaturalSpline> childNative)  : CCubicInterpolation(CCubicNaturalSpline::typeid)
{
	_phCubicNaturalSpline = &childNative;
	_ppCubicNaturalSpline = &static_cast<boost::shared_ptr<QuantLib::CubicNaturalSpline>>(childNative.currentLink());
    _ppCubicInterpolation = new boost::shared_ptr<QuantLib::CubicInterpolation> (boost::dynamic_pointer_cast<QuantLib::CubicInterpolation> (*_ppCubicNaturalSpline));
}
#endif
#ifdef STRUCT
Cephei::QL::Math::Interpolations::CCubicNaturalSpline::CCubicNaturalSpline (QuantLib::CubicNaturalSpline childNative)  : CCubicInterpolation(CCubicNaturalSpline::typeid)
{
#ifdef HANDLE
	_phCubicNaturalSpline = NULL;
#endif
	_ppCubicNaturalSpline = new boost::shared_ptr<QuantLib::CubicNaturalSpline> (new QuantLib::CubicNaturalSpline (childNative));
    _ppCubicInterpolation = new boost::shared_ptr<QuantLib::CubicInterpolation> (boost::dynamic_pointer_cast<QuantLib::CubicInterpolation> (*_ppCubicNaturalSpline));
}
#endif

Cephei::QL::Math::Interpolations::CCubicNaturalSpline::~CCubicNaturalSpline ()
{
    if (_ppCubicNaturalSpline != NULL)
    {
	    delete _ppCubicNaturalSpline;
        _ppCubicNaturalSpline = NULL;
    }
}
Cephei::QL::Math::Interpolations::CCubicNaturalSpline::!CCubicNaturalSpline ()
{
    if (_ppCubicNaturalSpline != NULL)
    {
	    delete _ppCubicNaturalSpline;
    }
}
QuantLib::CubicNaturalSpline& Cephei::QL::Math::Interpolations::CCubicNaturalSpline::GetReference ()
{
    if (_ppCubicNaturalSpline == NULL) throw gcnew NativeNullException ();
	return **_ppCubicNaturalSpline;
}
boost::shared_ptr<QuantLib::CubicNaturalSpline>& Cephei::QL::Math::Interpolations::CCubicNaturalSpline::GetShared ()
{
    if (_ppCubicNaturalSpline == NULL) throw gcnew NativeNullException ();
	return *_ppCubicNaturalSpline;
}
QuantLib::CubicNaturalSpline* Cephei::QL::Math::Interpolations::CCubicNaturalSpline::GetPointer ()
{
    if (_ppCubicNaturalSpline == NULL) throw gcnew NativeNullException ();
	return &**_ppCubicNaturalSpline;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::CubicNaturalSpline>& Cephei::QL::Math::Interpolations::CCubicNaturalSpline::GetHandle ()
{
	if (_phCubicNaturalSpline == NULL)
	{
		_phCubicNaturalSpline = new Handle<QuantLib::CubicNaturalSpline> (*_ppCubicNaturalSpline);
	}
	return *_phCubicNaturalSpline;
}
#endif
bool Cephei::QL::Math::Interpolations::CCubicNaturalSpline::HasNative () 
{
	return (_ppCubicNaturalSpline != NULL);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

